<?php

// no direct access
defined( '_VALID_MOS' ) or die( 'Restricted access' );

$_MAMBOTS->registerFunction( 'onBeforeDownload', 'CheckDocmanRights' );

function CheckDocmanRights( $params ) {
    global $mainframe;

    $result = array();
    if(!isset($_SESSION))  session_start();
    if (!mosGetParam($_SESSION,'docman'.$params['document']->id,0)){
        $result = array('_error' => 1, '_errmsg' => 'You must answer all the questions before to download the file.');
    }
    mosSession::set('docman'.$params['document']->id,0);
    return $result;

}

?>